﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SMTC.BO.Role;
using SMTC.WebCommon.Common;
using SMTC.Model.Model;

public partial class RoleManagement_RoleMaintain : BasePage
{
    RoleProcessService proc = new RoleProcessService();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        SMT_RoleModel role = new SMT_RoleModel();
        role.RoleID = Guid.NewGuid().ToString();
        role.RoleName = txt_RoleName.Text.Trim();
        role.Description = txt_RoleDescription.Text.Trim();
        if (proc.InsertRole(role) == true)
        {
            ShowMessage(Resources.Resource.AddRoleSuccess);
        }
        else
        {
            ShowMessage(Resources.Resource.AddRoleFail);
        }
        gvRoleList.DataBind();
    }
     protected void btnSearch_Click(object sender, EventArgs e)
    {
        this.gvRoleList.DataBind();
    }
    protected void gvRoleList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Del")
        {
            if (proc.DeleteRole(e.CommandArgument.ToString()))
            {
                ShowMessage(Resources.Resource.DelRoleSuccess);
            }
            else
            {
                ShowMessage(Resources.Resource.DelRoleFail);
            }
            this.gvRoleList.DataBind();
        }
    }
}
